﻿using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
using DiscoveryLogic.DataServices.DataSources;

namespace DiscoveryLogic.UI.Layouts.DataAccesses
{
    public partial class TradeHistoryNewsItem : INotifyPropertyChanged
    {
        #region Private Variables

        NewsTypes newsType;
        int id;
        DateTime newsDate;
        string headline;
        string body;        

        #endregion

        #region Constructors

        public TradeHistoryNewsItem(int id, NewsTypes type, string headline, string body, DateTime date) :
            this()
        {
            newsType = type;
            this.id = id;
            this.headline = headline;
            this.body = body;
            newsDate = date;
        }

        public TradeHistoryNewsItem()
        {
        }

        #endregion

        #region Get/Set

        public string Headline
        {
            get { return headline; }
            set { headline = value; }
        }

        public string Body
        {
            get { return body; }
            set { body = value; }
        }

        public NewsTypes NewsType
        {
            get { return newsType; }
            set { newsType = value; }
        }

        public int Id
        {
            get { return id; }
            set { id = value; }
        }

        public string Symbol
        {
            get { return Convert.ToChar(65 + id).ToString();  }
        }

        public DateTime NewsDate
        {
            get { return newsDate; }
            set { newsDate = value; }
        }

        public string Subheadline
        {
            get { return String.Format("{0} - {1}", body, newsDate.ToShortDateString()); }
        }

        #endregion

        #region Events

        public event PropertyChangedEventHandler PropertyChanged;

        public void NotifyPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion
    }
}
